{template 'common/header'}
<ul class="nav nav-tabs">
	<li {if $op == 'list'}class="active"{/if}><a href="{php echo $this->createWebUrl('slide',array('op' => 'list'))}">管理</a></li>
	<li {if $op == 'add'}class="active"{/if}><a href="{php echo $this->createWebUrl('slide',array('op' => 'add'))}">添加</a></li>
	
</ul>
<div class="main">
	<form class="form-horizontal form" action="" method="post" enctype="multipart/form-data" onsubmit="return check(this);">
		<input type="hidden" name="id" value="{$item[id]}">
		<div class="panel panel-default">
			<div class="panel-heading">
				幻灯片管理
			</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">排序</label>
					<div class="col-sm-4 col-xs-4">
						<input type="text" class="form-control" placeholder="" name="displayorder" value="{$item['displayorder']}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">标题</label>
					<div class="col-sm-4 col-xs-4">
						<input type="text" class="form-control" placeholder="" name="title" value="{$item['title']}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">缩略图</label>
					<div class="col-sm-4 col-xs-4">
						{php echo tpl_form_field_image('thumb', $item['thumb'])}
						<span class="help-block"></span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">链接</label>
					<div class="col-sm-4 col-xs-4">
						{php echo tpl_form_field_link('url', $item['url'], array('css' => array('input' => ' input-sm', 'btn' => ' btn-sm')));}
					</div>
				</div>
				<div class="form-group">
	                <label for="" class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">选择小区</label>
	                <div class="col-sm-10 col-xs-12">
	                    <label class="checkbox-inline">
                        	<input type="checkbox" id="checkAll" name="checkAll" data-group="regionid">全部
	                    </label>
	                    {loop $regions $region}
	                    <label class="checkbox-inline">
	                        <input type="checkbox" id="regionid" value="{$region['id']}" name='regionid[]' data-group="regionid" {if @in_array($region[ 'id'], $regs)}checked='checked' {/if}> {$region['city']}{$region['dist']}{$region['title']}
	                    </label>
	                    {/loop}
	                </div>
	            </div>
	            <div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
					<div class="col-sm-10 col-xs-10">
						<button type="submit" class="btn btn-primary col-lg-1" name="submit" value="提交">提交</button>
						<input type="hidden" name="token" value="{$_W['token']}" />
					</div>
				</div>
			</div>
		</div>
	</form>
</div>
<script type="text/javascript">
	function check(form){
            if (!form['title'].value) {
                alert('请输入幻灯标题。');
                return false;
            }
            if (!form['thumb'].value) {
                alert('请上传图片！');
                return false;
            }
            return true;
        }

	$(function() {
	    $("#checkAll").click(function() {

	        var checked = $(this).get(0).checked;
	        var group = $(this).data('group');
	        $("#regionid[data-group='" + group + "']").each(function() {
	            $(this).get(0).checked = checked;
	        })

	    });
	});

</script>

{template 'common/footer'}